package org.hawk.gwt.ppc.parser.impl.mock;

import java.lang.reflect.Constructor;
import java.lang.reflect.TypeVariable;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.google.gwt.user.client.DOM;

public class SimpleExpressionMock {
	int data;
	public Map<String, List<String>> map1 = new HashMap<String, List<String>>(), map2 = Collections.unmodifiableMap(new HashMap<String, List<String>>());
	
	public String unary(int a, boolean b) {
		a = -a;
		a = +a;
		++a;
		--a;
		a = ~a;
		b = !b;
		return "" + a + b;
	}
	
	public int postfixTest(int aaa) {
		aaa++;
		aaa--;
		return aaa;
	}
	
	public int binaryTest(int aaa, int bbb, int ccc) {
		ccc = aaa + bbb;
		ccc = aaa - bbb;
		ccc = aaa * bbb;
		ccc = aaa / bbb;
		ccc = aaa % bbb;
		ccc = aaa >> bbb;
		ccc = aaa << bbb;
		ccc = aaa >>> bbb;
		ccc = aaa | bbb;
		ccc = aaa & bbb;
		ccc = aaa ^ bbb;
		return ccc;
	}
	
	public boolean booleanTest(boolean aaa, boolean bbb, boolean ccc) {
		ccc = aaa && bbb;
		ccc = aaa || bbb;
		
		return ccc;
	}
	

	
	public boolean comparasionTest(int aaa, int bbb, boolean ccc, Number sss) {
		ccc = aaa > bbb;
		ccc = aaa < bbb;
		ccc = aaa >= bbb;
		ccc = aaa <= bbb;
		ccc = aaa == bbb;
		ccc = aaa != bbb;
		ccc = sss instanceof Integer;
		
		return ccc;
	}
	
	public int assignmentTest(int aaa, int bbb) {
		aaa += bbb;
		aaa /= bbb;
		aaa *= bbb;
		aaa -= bbb;
		aaa %= bbb;
		aaa ^= bbb;
		aaa &= bbb;
		aaa |= bbb;
		aaa >>= bbb;
		aaa >>>= bbb;
		aaa <<= bbb;
		
		return aaa;
	}
	
	public void testDot() {
		this.data = 5;
	}
	
	public String testLiterals(String aaa) {
		aaa += 5;
		aaa += 10.0d;
		aaa += 5e-1f;
		aaa += 5l;
		aaa += '\u3214';
		aaa += "some string";
		
		return aaa;
	}
	
	public double testTernary(boolean aaa, int bbb, int ccc) {
		bbb = aaa ? bbb : data;
		double direction = (bbb < ccc) ? 100.0 : -100.0;
		return direction;
	}
	
	public int testVar() {
		int var;
		var = 2;
		
		@SuppressWarnings("unused")
		final java.lang.Integer newVar = var * 2;
		return var;
	}
	
	public Object testNew() {
		new Integer("12");
		MemberClassMock mock = new MemberClassMock();
		mock.new InstanceMemberClass();
		new MemberClassMock.StaticMemberClass();
		new MemberClassMock().new InstanceMemberClass();
		new java.lang.Runnable(){

			public void run() {}
			
		};
		Object ss = new int[5][6][7];
		ss = new int[] {2, 4, 5, 12};
		return ss;
	}
	
	@SuppressWarnings("unused")
	public void testCast() {
		Object o = new MemberClassMock();
		MemberClassMock o1 = (MemberClassMock)o;
		MemberClassMock.StaticMemberClass o2 = (MemberClassMock.StaticMemberClass)o;
		MemberClassMock.InstanceMemberClass o3 = (MemberClassMock.InstanceMemberClass)o;
	}
	
	public void testMethodCall() {
		"a".charAt(0);
		"a".substring(0, 1);
	}
	
	public int testPriority() {
		int a = 1 + 2 * 3;
		a = (1 + 2) * 3;
		a = 2 * 3 + 1;
		
		return a;
	}
	
	public int testComa() {
		int a = 2, b = 3, c = 4;
		
		return a * b + c;
	}
	
	public TypeVariable<Constructor<SimpleExpressionMock>>[] testSubexpressions(int eventBitsToRemove) throws SecurityException, NoSuchMethodException {
		DOM.sinkEvents(null, DOM.getEventsSunk(null)
		        & (~eventBitsToRemove));
		TypeVariable<Constructor<SimpleExpressionMock>>[] vars1 = SimpleExpressionMock.class.getDeclaredConstructor(List[].class).getTypeParameters();
		return vars1;
	}
}
